/**
 *
 */
package com.codebase.oval.annotation.impl;
import com.codebase.oval.annotation.IDCardOval;
import com.codebase.oval.verify_rule.IDCardVerify;
import net.sf.oval.Validator;
import net.sf.oval.configuration.annotation.AbstractAnnotationCheck;
import net.sf.oval.context.OValContext;
import net.sf.oval.exception.OValException;

/**
 * describe: 身份证号码校验注解
 * author:houkai
 * Date: 2018/2/1 17:09
 * @version 1.0
 */
public class IDCardOvalImpl extends AbstractAnnotationCheck<IDCardOval> {

    @Override
    public boolean isSatisfied(Object validatedObject, Object valueToValidate, OValContext context, Validator validator) throws OValException {
        boolean flag = false;
        try{
            String value = (String) valueToValidate;
            flag = IDCardVerify.validateCard(value);
        } catch (Exception e){
            e.printStackTrace();
        }
        return flag;
    }
}
